<?php echo $html->css(array('datepicker')); ?>
<?php echo $javascript->link(array('jquery-1.4.2', 'jquery.jeditable', 'javaEdit', 'datepicker')); ?>
<script type="text/javascript">
$(document).ready(function(){
	// toggle the search form
	$('.search-toggle').click(function(){
		$('#SearchForm').toggle();
	});
	$('#SearchForm').hide();
});
</script>

<div class="timesheets index">
	<h2><?php __('Timesheets');?></h2>
        <center><?php echo $html->link(__('Search', true), 'javascript:void(0)', array('class'=>'search-toggle')); ?></center>
        <?php echo $form->create('Timesheet',array('action'=>'search', 'id'=>'SearchForm'));?>
	<fieldset class="search">
 		<legend><?php __('Search');?></legend>
	<?php
		echo '<center><b>'; 
		e($form->label('startDate', 'Start Date')); 		
		e($form->day('startDate', date('d'), array('id' => 'sd-dd'), false)." - ");
		e($form->month('startDate', date('m'), array('id' => 'sd-mm'), false)." - ");
		e($form->year('startDate', '1900', date('Y') + 50, date('Y'), array('id' => 'sd', 'class' => 'show-weeks dateformat-d-ds-m-ds-Y statusformat-l-cc-sp-d-sp-F-sp-Y highlight-days-67 split-date opacity-90'), false));
		echo "<br />";
		echo "<br />";		
		e($form->label('endDate', 'End Date'));
		echo '</b>'; 		
		e($form->day('endDate', date('d'), array('id' => 'ed-dd'), false)." - ");
		e($form->month('endDate', date('m'), array('id' => 'ed-mm'), false)." - ");
		e($form->year('endDate', '1900', date('Y') + 50, date('Y'), array('id' => 'ed', 'class' => 'show-weeks dateformat-d-ds-m-ds-Y statusformat-l-cc-sp-d-sp-F-sp-Y highlight-days-67 split-date opacity-90'), false));
		echo '<br />';
		echo '<br />';	
		echo $form->submit('Search');
		echo '</center>';
	?>
	</fieldset>
<?php echo $form->end();?>
        
        <div class="right"><?php echo '<b>'.$this->requestAction('/timesheets/getCountNotCompletedTimesheets/').'</b> '.$this->Html->link(__('Jobs', 'timesheets', true), array('controller' => 'timesheets', 'action' => 'viewStatus', 'Active')).' <b> not completed<br/><br />';?></div>
        <div class="right"><?php echo $this->Html->link(__('New Timesheet', true), array('action' => 'add')); ?></div>
        <br />
	<table cellpadding="0" cellspacing="0">
	<tr>            <th class="title"><?php echo $this->Paginator->sort('date');?></th>
			<th class="title"><?php echo $this->Paginator->sort('client_id');?></th>
                        <th class="title"><?php echo $this->Paginator->sort('Customer','customer name');?></th>
			<th class="title"><?php echo $this->Paginator->sort('user_id');?></th>
			<th class="title"><?php echo $this->Paginator->sort('type');?></th>
			<th class="title"><?php echo $this->Paginator->sort('location');?></th>
			<th class="title"><?php echo "Duration";?></th>
			<th class="actions"><?php __('Actions');?></th>
	</tr>
	<?php
	$i = 0;
	foreach ($timesheets as $timesheet):
		$class = null;
		if ($i++ % 2 == 0) {
			$class = ' class="altrow"';
		}
	?>
	<tr<?php echo $class;?>>
                <td><?php echo $timesheet['Timesheet']['date']; ?>&nbsp;</td>
		<td>
			<?php echo $this->Html->link($timesheet['Client']['name'], array('controller' => 'clients', 'action' => 'view', $timesheet['Client']['id'])); ?>
		</td>
                <td><?php echo $timesheet['Timesheet']['customer name']; ?>&nbsp;</td>
		<td>
			<?php echo $this->Html->link($timesheet['User']['username'], array('controller' => 'users', 'action' => 'view', $timesheet['User']['id'])); ?>
		</td>
		<td><?php echo $timesheet['Timesheet']['type']; ?>&nbsp;</td>
		<td><?php echo $timesheet['Timesheet']['location']; ?>&nbsp;</td>
		<td><?php $this->Number->precision($duration = ($timesheet['Timesheet']['finish time'] - $timesheet['Timesheet']['start time']),2);
                echo $duration; ?>&nbsp;</td>
	        <td class="actions">
			<?php echo $this->Html->link(__('View', true), array('action' => 'view', $timesheet['Timesheet']['id'])); ?>
			<?php echo $this->Html->link(__('Edit', true), array('action' => 'edit', $timesheet['Timesheet']['id'])); ?>
			<?php echo $this->Html->link(__('Delete', true), array('action' => 'delete', $timesheet['Timesheet']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $timesheet['Timesheet']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
	</table>
	<p>
	<?php
	echo $this->Paginator->counter(array(
	'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
	));
	?>	</p>

	<div class="paging">
		<?php echo $this->Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?>
	 | 	<?php echo $this->Paginator->numbers();?>
 |
		<?php echo $this->Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?>
	</div>
	
	<div class="right">
            <a href="http://192.168.3.51:8080/jasperserver/flow.html?_flowId=viewReportFlow&ParentFolderUri=%2Freports%2FTechhead&ndefined=&standAlone=true&reportUnit=%2Freports%2FTechhead%2FGeneral&output=pdf&j_username=jasperadmin&j_password=jasperadmin" target="_blank">Create Report</a> &nbsp &nbsp &nbsp &nbsp
              <?php echo $this->Html->link(__('New Pending Task', true), array('controller' => 'outstanding_tasks', 'action' => 'add'));?> &nbsp &nbsp &nbsp &nbsp
              <?php echo $this->Html->link(__('New Timesheet', true), array('action' => 'add')); ?> 
              
        </div>
</div>